package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author rainbow
 **/
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/add")
    public Object add(@RequestBody User user) {
        return userService.add(user);
    }

    @PostMapping("/info/{id}")
    public Object getInfo(@PathVariable Long id) {
        return userService.getInfo(id);
    }

    @PostMapping("/update")
    public Object update(@RequestBody User user) {
        return userService.update(user);
    }

    @PostMapping("/list")
    public Object list() {
        return userService.list();
    }
}
